﻿<%@ Page Language="C#" MasterPageFile="~/MasterPages/Core.Master" AutoEventWireup="true"
    CodeBehind="ReviewerWaitingList.aspx.cs" Inherits="Pap.Web.Modules.Loan.Views.ReviewerWaitingList"
    meta:resourcekey="PageResource1" %>

<%@ Register Src="../../Shared/Views/InsertAttchments.ascx" TagName="InsertAttchments"
    TagPrefix="uc1" %>
<asp:Content ContentPlaceHolderID="ContentPlaceHolder1" runat="server">

    <script type="text/javascript">
        var BoardDecisionRenderer = function(value) {
            var r = storeDecisions.getById(value);
            if (Ext.isEmpty(r)) {
                return "";
            }
            return r.data.DecisionName;
        }

        var LoanBeforeEdit = function(e) {
            switch (e.field) {
                case "DecisionID":
                    {
                        if (e.grid.getRowsValues(false)[e.row].Editable)
                            this.getColumnModel().getCellEditor(e.column, e.row).field.setDisabled(false);
                        else this.getColumnModel().getCellEditor(e.column, e.row).field.setDisabled(true);
                    }
                    break;
            }
        }
        
    </script>

    <ext:Store runat="server" ID="storeBoards" AutoLoad="True" IDMode="Legacy">
        <Reader>
            <ext:JsonReader ReaderID="BoardID">
                <Fields>
                    <ext:RecordField Name="BoardID" />
                    <ext:RecordField Name="CommitteeName" />
                    <ext:RecordField Name="ExpertName" />
                    <ext:RecordField Name="BoardNumber" />
                    <ext:RecordField Name="BoardDate" Type="Date" />
                    <ext:RecordField Name="BoardStatus" />
                    <ext:RecordField Name="PreviousNotes" />
                    <ext:RecordField Name="StatusNotes" />
                </Fields>
            </ext:JsonReader>
        </Reader>
        <SortInfo Direction="ASC"></SortInfo>
    </ext:Store>
    <ext:Store runat="server" ID="storeBoardLoans">
        <Reader>
            <ext:JsonReader ReaderID="LoanID">
                <Fields>
                    <ext:RecordField Name="LoanID" />
                    <ext:RecordField Name="LoanNumber" />
                    <ext:RecordField Name="LoanCreatedDate" Type="Date" />
                    <ext:RecordField Name="CustomerName" />
                    <ext:RecordField Name="LoanType" />
                    <ext:RecordField Name="BoardLoanAmount" />
                    <ext:RecordField Name="BoardPaymentPeriod" />
                    <ext:RecordField Name="BoardDecision" />
                    <ext:RecordField Name="PreviousNotes" />
                    <ext:RecordField Name="StatusNotes" />
                    <ext:RecordField Name="DecisionID" />
                    <ext:RecordField Name="Editable" />
                    <ext:RecordField Name="ActionTypeID" />
                </Fields>
            </ext:JsonReader>
        </Reader>
    </ext:Store>
    <ext:Store ID="storeDecisions" runat="server" IDMode="Static">
        <Reader>
            <ext:JsonReader ReaderID="DecisionID">
                <Fields>
                    <ext:RecordField Name="DecisionID" />
                    <ext:RecordField Name="DecisionName" />
                </Fields>
            </ext:JsonReader>
        </Reader>
        <SortInfo Direction="ASC"></SortInfo>
    </ext:Store>
    <ext:FitLayout runat="server">
        <ext:FormPanel runat="server" ID="fpanlBoardMom" AutoScroll="true">
            <Body>
                <ext:FormLayout runat="server">
                    <ext:Anchor>
                        <ext:GridPanel runat="server" ID="grvBoards" StoreID="storeBoards" Title="<%$ Resources:grvBoardsTitle %>"
                            TrackMouseOver="True" AutoHeight="true" AutoScroll="true" AutoWidth="True">
                            <ColumnModel>
                                <Columns>
                                    <ext:Column DataIndex="CommitteeName" Header="<%$ Resources:grvHeaderCommittee %>"
                                        Sortable="True" />
                                    <ext:Column DataIndex="ExpertName" Header="<%$ Resources:grvHeaderExpert %>" Sortable="True" />
                                    <ext:Column DataIndex="BoardNumber" Header="<%$ Resources:grvHeaderBoardNumber %>"
                                        Sortable="True" />
                                    <ext:Column DataIndex="BoardDate" Header="<%$ Resources:grvHeaderBoardDate %>" Sortable="True">
                                        <Renderer Fn="Ext.util.Format.dateRenderer('d/m/Y')" />
                                    </ext:Column>
                                    <ext:Column DataIndex="BoardStatus" Header="<%$ Resources:grvHeaderBoardStatus %>"
                                        Sortable="True" />
                                    <ext:Column DataIndex="PreviousNotes" Header="<%$ Resources:PreviousNotes %>" Sortable="false" />
                                    <ext:Column DataIndex="StatusNotes" Header="<%$ Resources:grvHeaderStatusNotes %>"
                                        Sortable="True">
                                        <Editor>
                                            <ext:TextArea ID="TextArea1" runat="server" />
                                        </Editor>
                                    </ext:Column>
                                </Columns>
                            </ColumnModel>
                            <SelectionModel>
                                <ext:RowSelectionModel runat="server">
                                    <AjaxEvents>
                                        <SelectionChange OnEvent="Board_Selected" Before="#{grvBoardLoan}.body.mask('...', 'x-mask-loading');"
                                            Success="#{grvBoardLoan}.body.unmask();" />
                                    </AjaxEvents>
                                </ext:RowSelectionModel>
                            </SelectionModel>
                        </ext:GridPanel>
                    </ext:Anchor>
                    <ext:Anchor>
                        <ext:GridPanel runat="server" ID="grvBoardLoan" StoreID="storeBoardLoans" Title="<%$ Resources:grvBoardLoansTitle %>"
                            TrackMouseOver="True" AutoHeight="true" AutoScroll="true">
                            <ColumnModel>
                                <Columns>
                                    <ext:Column DataIndex="LoanNumber" Header="<%$ Resources:grvHeaderLoanNumber %>"
                                        Sortable="True" />
                                    <ext:Column DataIndex="LoanCreatedDate" Header="<%$ Resources:grvHeaderLoanCreatedDate %>"
                                        Sortable="True">
                                        <Renderer Fn="Ext.util.Format.dateRenderer('d/m/Y')" />
                                    </ext:Column>
                                    <ext:Column DataIndex="LoanType" Header="<%$ Resources:grvHeaderLoanType %>" Sortable="True" />
                                    <ext:Column DataIndex="BoardLoanAmount" Header="<%$ Resources:grvHeaderBoardLoanAmount %>"
                                        Sortable="True" />
                                    <ext:Column DataIndex="BoardPaymentPeriod" Header="<%$ Resources:grvHeaderBoardPaymentPeriod %>"
                                        Sortable="True" />
                                    <ext:Column DataIndex="BoardDecision" Header="<%$ Resources:BoardDecision %>" Sortable="True" />
                                    <ext:Column DataIndex="PreviousNotes" Header="<%$ Resources:PreviousNotes %>" Sortable="True" />
                                    <ext:Column DataIndex="DecisionID" Header="<%$ Resources:grvHeaderLoanDecision %>"
                                        Sortable="True">
                                        <Renderer Fn="BoardDecisionRenderer" />
                                        <Editor>
                                            <ext:ComboBox runat="server" ID="cmbBoardDecision" StoreID="storeDecisions" DisplayField="DecisionName"
                                                ValueField="DecisionID" AllowBlank="False" TypeAhead="True" TriggerAction="All"
                                                Visible="False" />
                                        </Editor>
                                    </ext:Column>
                                    <ext:Column DataIndex="StatusNotes" Header="<%$ Resources:grvHeaderStatusNotes %>"
                                        Sortable="True">
                                        <Editor>
                                            <ext:TextArea runat="server" />
                                        </Editor>
                                    </ext:Column>
                                </Columns>
                            </ColumnModel>
                            <%-- <Listeners>
                                <BeforeEdit Fn="LoanBeforeEdit" />
                            </Listeners>--%>
                            <AjaxEvents>
                                <BeforeEdit OnEvent="DecisionBeforEdit">
                                    <ExtraParams>
                                        <ext:Parameter Name="ActionTypeID" Mode="Raw" Value="e.record.data.ActionTypeID"
                                            Encode="false" />
                                    </ExtraParams>
                                </BeforeEdit>
                            </AjaxEvents>
                        </ext:GridPanel>
                    </ext:Anchor>
                    <ext:Anchor>
                        <ext:Panel runat="server">
                            <Body>
                                <uc1:InsertAttchments runat="server" ViewMode="Display" ID="ucAttachment" />
                            </Body>
                        </ext:Panel>
                    </ext:Anchor>
                </ext:FormLayout>
            </Body>
            <BottomBar>
                <ext:StatusBar runat="server" meta:resourcekey="FormStatusBarResource1">
                    <Items>
                        <ext:Button runat="server" ID="btnCancle" Icon="ArrowUndo" meta:resourcekey="btnCancleResource1">
                            <AjaxEvents>
                                <Click OnEvent="BtnCancle_Clicked" />
                            </AjaxEvents>
                        </ext:Button>
                        <ext:Button ID="btnReturn" runat="server" Text="Return" Icon="Decline" meta:resourcekey="btnReturnResource1">
                            <AjaxEvents>
                                <Click OnEvent="btnReturn_Clicked">
                                    <ExtraParams>
                                        <ext:Parameter Name="grvBoards" Mode="Raw" Value="Ext.encode(#{grvBoards}.getRowsValues(true))" />
                                    </ExtraParams>
                                </Click>
                            </AjaxEvents>
                        </ext:Button>
                        <ext:Button runat="server" ID="btnSubmit" Text="Submit" Icon="Accept" meta:resourcekey="btnSubmitResource1">
                            <AjaxEvents>
                                <Click OnEvent="BtnSubmit_Clicked">
                                    <ExtraParams>
                                        <ext:Parameter Name="grvBoards" Mode="Raw" Value="Ext.encode(#{grvBoards}.getRowsValues(true))" />
                                        <ext:Parameter Name="grvBoardLoanGrid" Mode="Raw" Value="Ext.encode(#{grvBoardLoan}.getRowsValues(false))" />
                                    </ExtraParams>
                                </Click>
                            </AjaxEvents>
                        </ext:Button>
                    </Items>
                    <Plugins>
                        <ext:ValidationStatus ID="wndpnlValidation" FormPanelID="fpanlBoardMom" ValidIcon="Accept"
                            ErrorIcon="Exclamation" runat="server" meta:resourcekey="wndpnlValidationResource1" />
                    </Plugins>
                </ext:StatusBar>
            </BottomBar>
        </ext:FormPanel>
    </ext:FitLayout>
</asp:Content>
